<template>
	<view class="transfer">
		<view class="transfer_centent">
			<view class="transfer_one">
				<view class="transfer_one_left">
					当前KDJ
				</view>
				<view class="transfer_one_right">
					{{userInfo.kdj}}
				</view>
			</view>
			<view class="transfer_one">
				<view class="transfer_one_left">
					当前信誉分
				</view>
				<view class="transfer_one_right">
					{{userInfo.xinyu}}
				</view>
			</view>
			<view class="transfer_one">
				<view class="transfer_one_left">
					KDJ
				</view>
				<view class="transfer_one_right">
					<input type="number"  v-model="params.KDJ" placeholder="请输入KDJ">
				</view>
			</view>
			<div style="font-size: 28rpx;box-sizing: border-box;padding: 30rpx 0;color: #ff3d33;">
				注意：1KDJ={{kdj_xinyu}}信誉分
			</div>
		</view>
		<view class="transfer_button" @click="confirmTransfer">
			兑换
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				userInfo:"",
				params:{
					KDJ:"",
				},
				kdj_xinyu:"",
			}
		},
		onShow() {
			this.loadData()
			this.getBili()
		},
		methods:{
			async getBili(){
				await uni.request({
					url:"/wanlshop/Signin/xinyu",
					method:"POST",
					data:{},
					success:(res)=>{
						// console.log(res.data,'信誉分比例')
						this.kdj_xinyu=res.data.kdj_xinyu
					}
				})
			},
			async loadData() {
				await uni.request({
					url: '/wanlshop/user/refresh',
					method: 'POST',
					success: res => {
						this.userInfo=res.data.userinfo
						console.log(res.data.userinfo,'89999999999999999999999999999999999')
					}
				});
			},
			async confirmTransfer(){
				uni.showLoading({
					title:"加载中",
					mask:true
				})
				if(!this.params.KDJ)  return this.$wanlshop.msg('请输入兑换的信誉分')
				await uni.request({
					url: '/wanlshop/Signin/xinyu_order',
					method: 'POST',
					data:this.params,
					success: res => {
						uni.hideLoading()
						this.$wanlshop.msg('兑换成功')
						setTimeout(()=>{
							uni.navigateBack()
						},)
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.transfer{
		width: 100%;
		box-sizing: border-box;
		padding: 20rpx 24rpx;
		.transfer_centent{
			width: 100%;
			min-height: 100rpx;
			background-color: #ffffff;
			border-radius: 20rpx;
			box-sizing: border-box;
			padding: 0 20rpx;
			.transfer_one{
				width: 100%;
				height: 100rpx;
				border-bottom: 1rpx solid #f7f7f7;
				display: flex;
				align-items: center;
				.transfer_one_left{
					font-size: 30rpx;
					color: #333333;
					font-weight: 500;
				}
				.transfer_one_right{
					flex: 1;
					text-align: right;
					font-size: 30rpx;
					color: #333333;
					margin-left: 25rpx;
					input{
						width: 100%;
						height: 100rpx;
						font-size: 30rpx;
					}
				}
			}
		}
		.transfer_button{
			width: 500rpx;
			height: 90rpx;
			line-height: 90rpx;
			border-radius: 45rpx;
			text-align: center;
			background-color: #ff3d33;
			font-size: 30rpx;
			color: #ffffff;
			margin: 280rpx auto  0;
		}
	}
</style>